package com.shushan.home.bean;

import com.android.net.bean.NetBaseBean;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: rewardToyBean
 * @Desciption: 玩具奖励bean
 * @author: yichaohua
 * @date: 2018-04-16
 */
public class RewardToyBean extends NetBaseBean {

    public String name;//一级标题
    public String task;//二级标题
    public int type;
    public int practice_type;//1、同步练习 2、智能练习 3、边学边练 4、重点练习 5、难点练习 6、易错练习 7、专项练习
    public int special_id;
    public String description;
    public String pic;//图片地址
    public String complete_num;//完成人数
    public String training_num;//正在练习人数
    public boolean znlx;//智能练习是否有题；true有题；false无题；

    private List<String> description_list = new ArrayList<>();//描述列表
    private ScoreAchieveBean scoreAchieveBean;

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        name = jsonObject.optString("name","");
        task = jsonObject.optString("task","");
        type = jsonObject.optInt("type",1);
        practice_type = jsonObject.optInt("practice_type",1);
        special_id = jsonObject.optInt("special_id",0);
        description = jsonObject.optString("description","");
        pic = jsonObject.optString("pic","");
        complete_num = jsonObject.optString("complete_num","");
        training_num = jsonObject.optString("training_num","");
        znlx = jsonObject.optBoolean("znlx",false);
        JSONObject desObj = jsonObject.optJSONObject("description_list");
        if(desObj != null && desObj.length() > 0) {
            description_list.add(desObj.optString("0", ""));
            description_list.add(desObj.optString("7", ""));
            description_list.add(desObj.optString("8", ""));
            description_list.add(desObj.optString("9", ""));
        }

        JSONObject json = jsonObject.optJSONObject("toy_practice_score");
        if(json != null){
            scoreAchieveBean = new ScoreAchieveBean();
            scoreAchieveBean.initByJson(json);
        }
    }

    public ScoreAchieveBean getScoreAchieveBean() {
        return scoreAchieveBean;
    }

    public void setScoreAchieveBean(ScoreAchieveBean scoreAchieveBean) {
        this.scoreAchieveBean = scoreAchieveBean;
    }

    public List<String> getDescription_list() {
        return description_list;
    }
}
